<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
<#include "/jeecms_sys/head.html"/>
<script src="${base}/thirdparty/swfupload/swfupload.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/swfupload.queue.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/fileprogress.js" type="text/javascript"></script>
<script src="${base}/thirdparty/swfupload/handlers.js" type="text/javascript"></script>
<link href="${base}/thirdparty/swfupload/process.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function getTableForm() {
	return document.getElementById('tableForm');
}
function optDelete() {
	if(Pn.checkedCount('names')<=0) {
		alert("<@s.m 'error.checkRecord'/>");
		return;
	}
	if(!confirm("<@s.m 'global.confirm.delete'/>")) {
		return;
	}
	var f = getTableForm();
	f.action="o_delete.do";
	f.submit();
}
var swfu;
window.onload=function() {
	var uploadUrl = "o_swfupload.do";
	//在firefox、chrome下，上传不能保留登录信息，所以必须加上jsessionid。
	var jsessionid = $.cookie("JSESSIONID");
	if(jsessionid) {
		uploadUrl += ";jsessionid="+jsessionid;
	}
	swfu=new SWFUpload({
		upload_url : uploadUrl,
		flash_url : "${base}/thirdparty/swfupload/swfupload.swf",
		file_size_limit : "100 MB",
		post_params: {"root" : "${root}"},
		file_types : "*.html",
		file_types_description : "Html Files",
		file_queue_limit : 0,
		custom_settings : {
			progressTarget : "fsUploadProgress",
			cancelButtonId : "btnCancel"
		},
		debug: false,
		
		button_image_url : "${base}/thirdparty/swfupload/button_notext.png",
		button_placeholder_id : "spanButtonPlaceHolder",
		button_text: "<span class='btnText'><@s.m "resource.upload"/></span>",
		button_width: 81,
		button_height: 24,
		button_text_top_padding: 2,
		button_text_left_padding: 20,
		button_text_style: '.btnText{color:#666666; cursor:pointer;}',
		
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete2
	});
};
function queueComplete2(numFilesUploaded) {
	//刷新页面
	location.href="v_list.do?root=${root}";
}
</script>
</head>
<body>
<div class="box-positon">
	<div class="rpos"><@s.m "global.position"/>: <@s.m "template.function"/> - <@s.m "global.list"/></div>
	<form class="ropt">
	<input type="hidden" name="root" value="${root}"/>
	<@cms_perm url="/template/v_add.do">
&nbsp; <input type="submit" value="<@s.m "template.addTpl"/>" onclick="this.form.action='v_add.do';" class="create-template"/>
	</@cms_perm>
	</form>
	<div class="clear"></div>
</div>
<div class="body-box">
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="root" value="${root}"/>
<table border="0" style="padding-top:3px">
<tr>
	<td><@s.m "resource.currentDir"/>: ${root}</td>
	<@cms_perm url="/template/o_swfupload.do">
	<td width="70" align="center"><span id="spanButtonPlaceHolder"></span></td>
	<td><input class="cancel" id="btnCancel" type="button" value="<@s.m "global.cancel"/>" onclick="swfu.cancelQueue();" disabled="disabled" /></td>
	</@cms_perm>
	<@cms_perm url="/template/o_create_dir.do">
	<td>
&nbsp; <@s.m "template.addDir"/>: <input type="text" name="dirName" size="10" onkeypress="if(event.keyCode==13){$('#dirButton').click();return false;}"/>
		<input class="create-new" id="dirButton" type="submit" value="<@s.m "template.createDir"/>" onclick="this.form.method='post';this.form.action='o_create_dir.do';"/>
	</td>
	</@cms_perm>
</tr>
<tr><td colspan="4"><div id="fsUploadProgress"></div></td></tr>
</table>
</form>
<form id="tableForm" method="post">
<input type="hidden" name="root" value="${root}"/>
<@p.table value=list;template,i,has_next><#rt/>
	<@p.column title="<input type='checkbox' onclick='Pn.checkbox(\"names\",this.checked)'/>" width="20">
		<input type='checkbox' name='names' value='${template.name}'/><#t/>
	</@p.column><#t/>
	<@p.column title=" " width="20" align="center"><img src="${base}/res/common/img/file/${template.directory?string('folder','html')}.gif"/></@p.column><#t/>
	<@p.column code="template.filename">${template.filename}</@p.column><#t/>
	<@p.column code="template.size" align="right">${template.size} KB</@p.column><#t/>
	<@p.column code="template.lastModified" align="center">${template.lastModifiedDate?string('yyyy-MM-dd HH:mm:ss')}</@p.column><#t/>
	<@p.column code="global.operate" align="center">
		<@cms_perm url="/template/v_rename.do">
		<a href="v_rename.do?root=${root?url}&name=${template.name?url}" class="pn-opt"><@s.m "template.rename"/></a> | <#rt/>
		</@cms_perm>
		<@cms_perm url="/template/v_edit.do">
		<a <#if !template.directory>href="v_edit.do?root=${root?url}&name=${template.name?url}" class="pn-opt"<#else>disabled="disabled"</#if>><@s.m "global.edit"/></a> | <#rt/>
		</@cms_perm>
		<@cms_perm url="/template/o_delete_single.do">
		<a href="o_delete_single.do?root=${root?url}&name=${template.name?url}" onclick="if(!confirm('<@s.m "global.confirm.delete"/>')) {return false;}" class="pn-opt"><@s.m "global.delete"/></a><#t/>
		</@cms_perm>
	</@p.column><#t/>
</@p.table>
<div  style="margin-top:15px;">
	<@cms_perm url="/template/o_delete.do">
	<input type="button" value="<@s.m "global.delete"/>" onclick="optDelete();" class="del-button"/>
	</@cms_perm>
</div>
</form>
</div>
<#include "/common/alert_message.html"/>
</body>
</html>